///
/// ArmyBodger 3
/// (c)2010 richyp
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArmyBodger.Core {
    /// <summary>
    /// An Entry upgrade that applies Entry wide rather than per Unit
    /// </summary>
    public class Upgrade {
        /// <summary>
        /// The Equipment instance referred to by this Upgrade
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// The Equipment instance referred to by this Upgrade
        /// </summary>
        public Equipment Equipment { get; set; }
        /// <summary>
        /// Is the cost of the upgrade per unit, or unit wide?
        /// </summary>
        public bool CostIsUnitWide { get; set; }
        /// <summary>
        /// The cost of this upgrade
        /// </summary>
        public int Cost { get; set; }
        /// <summary>
        /// If the upgrade is applied call the script method referred to here
        /// </summary>
        public string OnUpgradeEvent { get; set; }
        /// <summary>
        /// Is the Upgrade active/applied ?
        /// </summary>
        public bool Applied { get; set; }
        /// <summary>
        /// Is the Upgrade automatically applied on entry creation?
        /// </summary>
        public bool Default { get; set; }
        /// <summary>
        /// Create a new copy of this Upgrade instance
        /// </summary>
        /// <returns>A new instance of Upgrade that is a clone of this one</returns>
        public Upgrade Copy() {
            return Upgrade.Copy(this);
        }
        /// <summary>
        /// Static copy method that takes an Upgrade option to clone instead of
        /// this instance
        /// </summary>
        /// <param name="source">The Upgrade object to clone</param>
        /// <returns>A new instance of Upgrade with the same values as source</returns>
        public static Upgrade Copy(Upgrade source) {
            Upgrade upgrade = new Upgrade();
            upgrade.Name = source.Name;
            upgrade.Equipment = source.Equipment;
            upgrade.CostIsUnitWide = source.CostIsUnitWide;
            upgrade.Cost = source.Cost;
            upgrade.OnUpgradeEvent = source.OnUpgradeEvent;
            upgrade.Applied = source.Applied;
            upgrade.Default = source.Default;
            return upgrade;
        }
        /// <summary>
        /// Overriden to display the name of the Upgrade
        /// </summary>
        /// <returns></returns>
        public override string ToString() {
            if(this.Equipment != null)
                return this.Equipment.Name + "| " + Applied.ToString();
            
            return "";
        }       
    }
}
